﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HuaHan.WorkTicket.Domain
{
    [Table("tblDepartment")]
    public partial class Department:BaseEntity
    {
        [Key]
        public System.Guid DepartmentID { get; set; }

        [Required]
        [DisplayName("上级部门")]
        public System.Guid ParentID { get; set; }

        [Required]
        [MaxLength(20)]
        [DisplayName("部门名称")]
        public string Name { get; set; }

        [MaxLength(20)]
        [DisplayName("部门电话")]
        public string Phone { get; set; }

        [MaxLength(100)]
        [DisplayName("描述")]
        public string Description { get; set; }

        [DisplayName("是否顶级部门")]
        public bool IsTop { get; set; }

        [NotMapped]
        public List<Department> ChildDepartmentList { get; set; }

        [NotMapped]
        public string ParentDepartmentName { get; set; }

        [NotMapped]
        public bool HasChildDepartment
        {
            get
            {
                if (this.ChildDepartmentList != null && this.ChildDepartmentList.Count() > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
}
